package com.yeung.spel;

import java.util.HashMap;
import java.util.Map;

/**
 * 静态工厂方法:直接调用一个类的静态方法就可以返回Bean的实列
 */
public class StaticCarFactory {
    private static Map<String, Car> cars = new HashMap<>();

    static {
        cars.put("audi", new Car(1, "audi", 393994, 322, null));
        cars.put("ford", new Car(31, "ford", 39313994, 333, null));
    }

    //静态工厂方法创建 对象
    public static Car getCar(String name) {
        return cars.get(name);
    }
}
